<template>
  <div>
<!--    添加按钮-->
    <div class="add" v-if="state1" v-show="state">
    <el-button type="primary" plain @click="add"  style="width: 100px;height: 50px">添加按钮</el-button>
  </div>
<!--    添加操作的弹框-->
    <div v-if="!state1" class="add1">
      <el-form ref="form" :model="sizeForm" label-width="80px" size="mini"  style="width: 400px">
        <el-form-item label="医院名称">
          <el-input v-model="sizeForm.name" ></el-input>
        </el-form-item>
        <el-form-item label="活动地址">
          <el-input v-model="sizeForm.name" ></el-input>
        </el-form-item>

        <el-form-item size="large">
          <el-button type="primary" @click="onSubmit" style="width: 100px;height: 50px">立即添加</el-button>
          <el-button @click="quxiao1" style="width: 100px;height: 50px">取消</el-button>
        </el-form-item>
      </el-form>
    </div>
<!--    内容模块-->
    <div v-show="state" v-if="state1">
  <el-table
      :data="tableData"
      style="width: 100%">
    <el-table-column
        align="center"
        label="医院名称"
        width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column
        align="center"
        label="医院地址"
        width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.address }}</span>
      </template>
    </el-table-column>
    <el-table-column label="操作" align="center">
      <template slot-scope="scope">
        <el-button
            style="width: 50px;height: 50px"
            size="mini"
            @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button
            size="mini"
            type="danger"
            style="width: 50px;height: 50px"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
    </div>
<!--    弹出框-->
    <div v-show="!state" class="add1">
      <el-form ref="form" :model="sizeForm" label-width="80px" size="mini" style="width: 400px">
        <el-form-item label="医院名称">
          <el-input v-model="sizeForm.name"></el-input>
        </el-form-item>
        <el-form-item label="医院地址">
          <el-input v-model="sizeForm.name"></el-input>
        </el-form-item>
        <el-form-item size="large">
          <el-button type="primary" @click="onSubmit" style="width: 100px;height: 50px"> 立即修改</el-button>
          <el-button @click="quxiao" style="width: 100px;height: 50px">取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name:'test5',
  data() {
    return {
      state:true,
      state1:true,
      //修改里的属性
      sizeForm: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      //添加里的属性
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      //内容框
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }]
    }
  },
  methods: {
    handleEdit(index, row) {
      this.state = false
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    quxiao(){
      this.state = true
    },
    quxiao1(){
      this.state1 = true
    },
    add(){
      this.state1 = false
    },
    onSubmit() {
      console.log('submit!');
    }

  }
}
</script>

<style scoped>
*{
  margin: 0;
  padding: 0;
}
.add{
  position:relative;
  top: 10px;
  left: 780px;
  width: 100px;
  height: 50px;

  z-index: 1000;
}
/*添加弹出框的属性*/
.add1{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}
</style>
